package com.zdb.order.service;

import com.zdb.order.entity.ProductInfo;
import com.zdb.order.mapper.ProductInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author Lx
 * @Date 2020/8/29 18:20
 * @Version 1.0
 */
@Service
public class ProductInfoService {
    @Autowired
    private ProductInfoMapper productInfoMapper;

    /**
     * 商品id数组，查询商品
     * @param ids
     * @return
     */
    public List<ProductInfo> getProductInfoByIds(String[] ids){
        List<ProductInfo> listProInfo = new LinkedList<>();
        for(String id:ids){
            ProductInfo productInfo = productInfoMapper.selectById(id);
            if(!StringUtils.isEmpty(productInfo)){
                listProInfo.add(productInfo);
            }
        }
        return listProInfo;
    }


}
